#!/bin/bash
###
 # @Date: 2020-10-27 19:13:07
 # @LastEditors: Tonser
 # @LastEditTime: 2020-11-30 15:11:47
 # @FilePath: /SwarmScripts/install/install_realsense.sh
 # @Description: start 启动脚本 使用前需要执行config.sh
### 


# 运行mavros
PASSWD="up"

echo $PASSWD | sudo -S apt-key adv --keyserver keys.gnupg.net --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo bionic main" -u
sudo apt-get install librealsense2-dkms -y
sudo apt-get install librealsense2-utils -y
sudo apt-get install librealsense2-dev -y
mkdir -p ~/realsense_ws/src
cd ~/realsense_ws/src/
git clone https://github.com/IntelRealSense/realsense-ros.git
cd realsense-ros/
git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
cd ..
catkin_init_workspace
cd ..
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
echo "source ~/realsense_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc